//
//  HWSheZhiLanguageViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2021/4/15.
//  Copyright © 2021 Chendaobin. All rights reserved.
//

#import "HWSheZhiLanguageViewController.h"

#import "DAConfig.h"
#import "NSBundle+DAUtils.h"

#import "HWTabBarController.h"


@interface HWSheZhiLanguageViewController ()
@property(strong,nonatomic) UIButton *but1;
@property(strong,nonatomic) UIButton *but2;

@end

@implementation HWSheZhiLanguageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    self.but1 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.but1.frame = CGRectMake(50, 200, 100, 100);
    [self.but1 addTarget:self action:@selector(button1Tap) forControlEvents:UIControlEventTouchUpInside];
    [self.but1  setTitle:@"简体中文" forState:UIControlStateNormal];
    self.but1.backgroundColor  = [UIColor redColor];
    
    [self.view addSubview:self.but1];
    
    
     
    
    self.but2 = [UIButton buttonWithType:UIButtonTypeCustom];
    self.but2.frame = CGRectMake(200, 200, 100, 100);
    [self.but2 addTarget:self action:@selector(button2Tap) forControlEvents:UIControlEventTouchUpInside];
    [self.but2  setTitle:@"English" forState:UIControlStateNormal];
    self.but2.backgroundColor  = [UIColor yellowColor];
    [self.view addSubview:self.but2];
    
    
    
    
    
    
}


- (void)button1Tap {
    
     
      [DAConfig setUserLanguage:@"zh-Hans"];
    
    
    
    
    
    HWSheZhiLanguageViewController *shezhi = [[HWSheZhiLanguageViewController alloc]init];

    HWTabBarController *tbc = [[HWTabBarController alloc] init];
    tbc.selectedIndex = 4;
    
  
    
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [UIApplication sharedApplication].keyWindow.rootViewController = tbc;
        
        UINavigationController *nvc = tbc.selectedViewController;
        [nvc pushViewController:shezhi animated:NO];
        
         
        NSLog(@"已切换到语言 %@", [NSBundle currentLanguage]);
    });
    
    
    
    
    
    
    
    
    
     
    
}



- (void)button2Tap {
    
    
    
      [DAConfig setUserLanguage:@"en"];
    
    
    
    HWSheZhiLanguageViewController *shezhi = [[HWSheZhiLanguageViewController alloc]init];

    HWTabBarController *tbc = [[HWTabBarController alloc] init];
    tbc.selectedIndex = 4;
    
  
    
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [UIApplication sharedApplication].keyWindow.rootViewController = tbc;
        
        UINavigationController *nvc = tbc.selectedViewController;
        [nvc pushViewController:shezhi animated:NO];
        
         
        NSLog(@"已切换到语言 %@", [NSBundle currentLanguage]);
    });
    
    
    
    
}










- (void)setUpUI  {
    
    
    
    
}










@end
